import { h } from 'vue';
import { mountComponent } from '@/utils/mount-component';
import ModelForm from './index.vue';

function createInstance (props) {
	const { unmount } = mountComponent({
		setup () {
			let attrs = {
				dialogVisible : true,
				close : () => {
					unmount();
				}
			};
			return () => {
				return h(ModelForm, { config : { ...attrs, ...props } });
			};
		}
	});
}
function dialogForm (props) {
	createInstance(props);
}

dialogForm.install = app => {
	app.component('DialogForm', ModelForm);
	app.config.globalProperties.$hyDialogForm = dialogForm;
};

export default dialogForm;
